package com.jic.manager.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.manager.mapper.ProductCommentReplyMapper;
import com.jic.manager.entity.ProductCommentReply;
import com.jic.conf.response.ProductCommentReplyResponse;
import com.jic.manager.service.ProductCommentReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品评论回复表
 * @author : 
 * @email : 
 * @since : 2020-02-10 05:50:20
 * @version : v1.0.0
 */
@Service
public class ProductCommentReplyServiceImpl implements ProductCommentReplyService {

    @Autowired
    private ProductCommentReplyMapper productCommentReplyMapper;

    @Override
    public long insert(ProductCommentReply productCommentReply) {
        long flag = productCommentReplyMapper.insert(productCommentReply);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return productCommentReplyMapper.delete(id);
    }

    @Override
    public long update(ProductCommentReply productCommentReply) {
        return productCommentReplyMapper.update(productCommentReply);
    }

    @Override
    public ProductCommentReply queryByPrimaryKey(Long id){
        return productCommentReplyMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<ProductCommentReply> query(ProductCommentReply productCommentReply){
        return productCommentReplyMapper.query(productCommentReply);
    }

    @Override
    public PageResult<ProductCommentReplyResponse> queryPage(ProductCommentReply productCommentReply, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<ProductCommentReply> list = productCommentReplyMapper.queryPage(startIndex, pageQuery.getLimit(), productCommentReply);
        long count = productCommentReplyMapper.queryPageCount(productCommentReply);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}